$(function () {

});

function searchData() {
    var table = layui.table, layer = layui.layer;

    table.init('serviceTable',{
        data: [
            {
                id:1,
                "CSDXZ": "",
                "JZZSLH": "4401172010101807520",
                "DJRQ": "2010-10-18",
                "HJXZ": "广东省韶关市曲江区****",
                "JZZYXQXQSSJ": "",
                "SJGXSJ": "2018-09-13 22:58:02",
                "XB": "女",
                "JZZYXQXJSSJ": "",
                "ZZBH": "从化区太平镇广从路273号宿舍",
                "MZ": "汉",
                "SJCZLX": "I",
                "CSRQ": "1991-10-19",
                "FZRQ": "2010-12-28",
                "PCH": "",
                "GMSFHM": "440221********0622",
                "XM": "郭**",
                "ZXRQ": "",
                "HJDZ": "440205",
                "SQ": ""
            }
        ]
        , toolbar: true
        , title: '广东省居住证基本信息'
        , page: true
    });

    //监听行工具事件
    table.on('tool(serviceTable)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
        var data = obj.data //获得当前行数据
            , layEvent = obj.event; //获得 lay-event 对应的值

        if (layEvent === 'detail') {
            loadDetail(data.id)
        }
    });
}

function loadDetail(id) {
    var data = [
        {
            id:1,
            "CSDXZ": "",
            "JZZSLH": "4401172010101807520",
            "DJRQ": "2010-10-18",
            "HJXZ": "广东省韶关市曲江区****",
            "JZZYXQXQSSJ": "",
            "SJGXSJ": "2018-09-13 22:58:02",
            "XB": "女",
            "JZZYXQXJSSJ": "",
            "ZZBH": "从化区太平镇广从路273号宿舍",
            "MZ": "汉",
            "SJCZLX": "I",
            "CSRQ": "1991-10-19",
            "FZRQ": "2010-12-28",
            "PCH": "",
            "GMSFHM": "440221********0622",
            "XM": "郭**",
            "ZXRQ": "",
            "HJDZ": "440205",
            "SQ": ""
        }
    ];


    var data0 = data[parseInt(id) - 1]
    $('#detailD').html(template('detailDS',{data:data0}));
    layer.open({
        type: 1,
        content: $("#detail"),
        area: ['900px', '550px'],
        title: '广东省居住证基本信息详情',
        maxmin: true,
        shade: 0,
        cancel: function () {
            $("#detail").hide()
        }
    });


}